#ifndef _physicsobject_h__
#define _physicsobject_h__
#include "Box2D/Box2D.h"
#include "math/vector.h"
#include "gtl/list.h"

namespace gecko
{

class PhysicsWorld;

class ShapeDef
{
public:
	enum Type
	{
		Type_None,
		Type_Circle,
		Type_Poly,
	};

	static const int MAX_VERTS = 8;

	Type		Type;
	float		Density;
	float		Radius;
	Vector3f	Offset;					// offset when shape is a circle
	Vector3f	PolyVerts[MAX_VERTS];
	char		NumVerts;
};

class BodyDef
{
public:
	enum Type
	{
		Type_Static,
		Type_Dynamic,
		Type_Kinematic,
	};

	static const int MAX_SHAPES = 8;

	float		Restitution;
	Type		BodyType;
	float		Friction;
	bool		FixedRotation;
	Vector3f	SpriteOffset;
	ShapeDef	Shapes[MAX_SHAPES];
	char		NumShapes;
};

class PhysicsObject
{
public:
	// constructor
	PhysicsObject(PhysicsWorld * world, const BodyDef & def, const Vector3f & position);

	// get the world position
	void GetPosition(Vector3f & pos);

	// get the rotation of the body
	float GetRotation();

	// apply a force at a world position
	void ApplyForce(const Vector3f & force, const Vector3f & worldPosition);

	// set the velocity of the body
	void SetLinearVelocity(const Vector3f & velocity);

	// get the velocity of the body
	void GetLinearVelocity(Vector3f & velocity);

	// set the friction of all ships attached to the body
	void SetFriction(float friction);

	// set the restitution of all ships attached to the body
	void SetRestitution(float restitution);

//private:
	b2Body * m_body;
};

}

#endif